#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int a[N];
int m , n;
int find(int x)
{
    int left = 1 , right = m;
    while(left < right)
    {
        int mid = (left + right) / 2;
        if(a[mid] >= x) right = mid;
        else left = mid + 1;
    }
    return left;
}
signed main()
{
    int ret = 0;
    a[0] = -2e7 + 10;
    cin >> m >> n;
    for(int i = 1;i <= m;i ++) cin >> a[i];
    sort(a + 1 , a + 1 + m);
    for(int i = 1;i <= n;i++)
    {
        int b; cin >> b;
        int pos = find(b);
        ret += min(abs(a[pos] - b) , abs(a[pos - 1] - b));
    }
    cout << ret << endl;
    return 0;
}